package com.edu.service.impl;

import com.edu.service.BookService;

/**
 *  BookServiceProxy 是 BookServiceImpl的代理类
 *      是负责对 BookServiceImpl 进行增强的
 *          1. 实现 和 被代理类一样的接口
 */
public class BookServiceProxy implements BookService {

    private BookService bs;

    public BookServiceProxy(BookService bs) {
        this.bs = bs;
    }

    @Override
    public void selectBook() {
        long start = System.currentTimeMillis();
        bs.selectBook();
        long end = System.currentTimeMillis();
        System.out.println("运行该方法耗时"+(end-start));
    }

    @Override
    public void addBook() {
        long start = System.currentTimeMillis();
        bs.addBook();
        long end = System.currentTimeMillis();
        System.out.println("运行该方法耗时"+(end-start));
    }

    @Override
    public void deleteBook() {
        long start = System.currentTimeMillis();
        bs.deleteBook();
        long end = System.currentTimeMillis();
        System.out.println("运行该方法耗时"+(end-start));
    }

    @Override
    public void updateBook() {
        long start = System.currentTimeMillis();
        bs.updateBook();
        long end = System.currentTimeMillis();
        System.out.println("运行该方法耗时"+(end-start));
    }

    @Override
    public void selectAllBook() {
        System.out.println("执行了查询所有书");
    }

    @Override
    public void deleteAllBook() {

    }
}
